namespace Arcane.Source.Combat.StatusEffects
{
    public class Burning(int duration, float damage) : TimerEffect(duration)
    {
        private float _damage = damage;
        public override void OnStack(ITrigger trigger)
        {
            if (trigger is not Burning i) return;

            _damage = (_damage * _timer + i._damage * i._timer) / (_timer + i._timer);
            _timer += i._timer;
        }

        public override void OnTick(Entity host)
        {
            if ((int)_timer % 30 == 0)
            {
                host.Hurt(DamageType.Magical, _damage);
            }

            base.OnTick(host);
        }
    }
}